import java.util.Scanner;

public class Main1721 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for (int i=5;i<=n;i++){
            if (i%10==5||i%10==8){
                System.out.println(i);
            }
        }
    }
}
